import java.util.Arrays;

/**
 * Created With IntelliJ IDEA
 * Description:牛客网：BM86 大数加法
 * <a href="https://www.nowcoder.com/practice/11ae12e8c6fe48f883cad618c2e81475?tpId=295&tqId=1061819&ru=/exam/company&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Fcompany">...</a>
 * User: DELL
 * Data: 2023-03-28
 * Time: 22:26
 */

public class Solution {
    public String solve (String s, String t) {
        if (s.length() == 0) {
            return t;
        } else if (t.length() == 0) {
            return s;
        }
        //调整一下，让s成为较长的那个字符串
        if (s.length() < t.length()) {
            String temp = s;
            s = t;
            t = temp;
        }
        char[] res = new char[s.length()];
        int carry = 0;
        for (int i = s.length()-1; i >= 0; i--) {
            int temp = s.charAt(i) - '0' + carry;
            if (s.length() - i <= t.length()) {
                temp += t.charAt(t.length() + i - s.length()) - '0';
            }
            carry = temp / 10;
            temp = temp % 10;
            res[i] = (char) (temp + '0');
        }
        String output = new String(res);
        if (carry == 1) {
            output =  "1" + output;
        }
        return output;
    }
}